import request from '@/utils/request.js'

// 获取所有角色列表
export const getRoleList = val => {
  return request({
    url: '/sys/role',
    method: 'get',
    params: val
  })
}

// 根据id查询企业
export const getCompanyInfo = companyId => {
  return request({
    url: `/company/${companyId}`,
    method: 'get'
  })
}

// 根据id删除角色
export const deleteRole = id => {
  return request({
    url: `/sys/role/${id}`,
    method: 'DELETE'
  })
}

// 根据ID获取角色详情
export const getRoleDetail = id => {
  return request({
    url: `/sys/role/${id}`,
    method: 'get'
  })
}

// 根据id编辑角色
export function updateRole(val) {
  return request({
    url: `/sys/role/${val.id}`,
    data: val,
    method: 'put'
  })
}

// 新增角色
export const addRole = val => {
  return request({
    url: '/sys/role',
    method: 'post',
    data: val
  })
}

// 给角色分配权限
export function assignPerm(data) {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
